package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
public class Scene extends BaseDomain {
    public static final Integer TYPE_ADULT = 0; // 成人票
    public static final Integer TYPE_CHILD = 1; // 儿童票
    public static final Integer TYPE_STUDENT = 2; //学生票
    public static final Integer TYPE_PARENT_AND_CHILD = 3; //亲子票
    public static final Integer TYPE_FAMILY = 4; // 家庭票
    public static final Integer TYPE_LOVERS = 5; // 情侣票
    public static final Integer TYPE_ELDERS = 6; // 老人票
    public static final Integer TYPE_SOLDIER = 7; // 军人票
    public static final Integer TYPE_DISABLED = 8; //残疾人票

    public static final Integer ONLINE = 0; // 在线支付
    public static final Integer OFFLINE = 1; // 线下支付

    private String name; // 景点名称

    private Theme theme; // 景点所属主题

    private Region region; // 景点所在区域

    private String coverUrl; // 景点的封面图片

    private BigDecimal price; // 景点的票价

    private String address; // 景点的地址

    private Integer wayOfPay = ONLINE; // 门票的支付方式

    private Integer type = TYPE_ADULT; // 门票的类型

    public String getTypeName() {
        String msg = "成人票";
        if (type == TYPE_CHILD) {
            msg = "儿童票";
        } else if (type == TYPE_DISABLED) {
            msg = "残疾人票";
        } else if (type == TYPE_ELDERS) {
            msg = "老人票";
        } else if (type == TYPE_FAMILY) {
            msg = "家庭票";
        } else if (type == TYPE_LOVERS) {
            msg = "情侣票";
        } else if (type == TYPE_PARENT_AND_CHILD) {
            msg = "亲子票";
        } else if (type == TYPE_SOLDIER) {
            msg = "军人票";
        } else if (type == TYPE_STUDENT) {
            msg = "学生票";
        }
        return msg;
    }

    public String getWayOfPayName() {
        String msg = "线上支付";
        if (wayOfPay == OFFLINE) {
            msg = "线下支付";
        }
        return msg;
    }

    public String getJson() {
        Map<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("name", name);
        map.put("coverUrl", coverUrl);
        map.put("address", address);
        map.put("price", price);
        map.put("wayOfPay", wayOfPay);
        map.put("type", type);
        if (theme != null) {
            map.put("themeId", theme.getId());
        }
        if (region != null) {
            map.put("regionId", region.getId());
        }
        return JSONUtil.toJSONString(map);
    }
}